
var path = require('path');
const fs = require('fs');
function changeFilejs(path) {
    let scriptData = fs.readFileSync(path, { encoding: 'utf-8' });
    scriptData = scriptData.replace('require("protobufjs/minimal")', 'require("./protobuf.js")');
    fs.writeFileSync(path, scriptData);
}
function changeFilets(path) {
    let scriptData = fs.readFileSync(path, { encoding: 'utf-8' });
    scriptData = scriptData.replace('/** Namespace JhaoProto', 'import * as $protobuf from "protobufjs";\n/** Namespace JhaoProto');
    fs.writeFileSync(path, scriptData);
}

var filePath = path.resolve('./jhaoproto.js');
var filePath2 = path.resolve('./jhaoproto.d.ts');

async function run() {
    await changeFilejs(filePath);
    await changeFilets(filePath2);
}

run();